import apis from '@/api/apis.js'

export default {
	namespaced: true,
	state: {
		pageNum: 1,
		pageSize: 10,
		total: 0,
		godl:[],
		fundHotList: [],
		fundRankList: [],
		fundExpList: [],
		selectType: 'hot'
	},
	mutations: {
		// setCurrentPage(state) {
		// 	state.pageNum++
		// },
		// 恢复默认的Page
		setUnloadPage(state) {
			state.pageNum = 1;
			pageSize: 10
		},
		//热门
		setFundHot(state, newData) {
			state.fundHotList = newData
		},
		// 修改selectType
		setType(state, newData) {
			state.selectType = newData
		},
		//拿去所有黄金
		setgodl(state, newData){
			console.log(newData)
			state.godl=newData
		}
	},
	actions: {
		// 获取基金热门
		async getFundHot(context) {
			let result = await apis.manager.fundHot({
				pageNum: context.state.pageNum,
				pageSize: context.state.pageSize,

			}, {
				selectType: context.state.selectType
			})
			context.commit('setFundHot', result)
		},
		// 基金页面详情
		async getFundDetails(context, fundCode) {
			return await apis.manager.fundDetails({
				fundCode
			})
		},
		// 购买页基金详情
		async getfundDes(context, fundCode) {
			return await apis.manager.fundDes({
				fundCode
			})
		},
		// 最近5天走向
		async getfundTrend(context, fundCode) {
			return await apis.manager.fundTrend({
				days: "6"
			}, {
				fundCode
			})
		},
		//黄金列表
		async getgold(context) {
			let data= await apis.manager.getgold({
				pageNum:1,
				pageSize: 200
			})
			context.commit(`setgodl`,data)
		}
	}
}
